package com.learn.security.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author : Yu.Tan
 * @date : 2022/11/16 16:43
 * @desc : **
 */
@Component
public class SecurityBeanConfig {

    /**
     * Spring Security在认证操作时会使用我们定义的这个加密器，如果没有则会出现异常。
     *
     * @return 加密器Bean
     */
    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
